package String;

public class String定义 {
    public static void main(String[] args) {
        //普通定义直接定义
        String name="朱佳铖";
        System.out.println(name);
        //用构造器定义
        String name1= new String();
        name1="sb";
        System.out.println(name1);
        String name2=new String("我是你爸爸");
        System.out.println(name2);
        //3.能把字符数组组合在一起
        char[] n3={'朱','佳','铖','好','帅'};
        String name3=new String(n3);
        System.out.println(name3);
        //4.能把byte值换成字符
        byte[] n4={65,66,67,68,69};
        String name4=new String(n4);
        System.out.println(name4);
        System.out.println("--------------------");
        String s1="abc";
        String s2="abc";
        System.out.println(s1==s2);
        char[] abc={'a','b','c'};
        String s3=new String(abc);
        String s4=new String(abc);
        System.out.println(s3);//abc
        System.out.println(s4);//abc
        System.out.println(s3==s4);///false比较地址
        System.out.println(s3.equals(s4));//true
        //
        String j="abc";
        String k="a"+"b"+"c";//自动变成"abc";
        System.out.println(j==k);//true地址相同
    }
}
